//
//  HomeTableViewController.swift
//  DSWeiBo
//
//  Created by iOS聚商 on 2017/6/27.
//  Copyright © 2017年 dreamSun. All rights reserved.
//

import UIKit

class HomeTableViewController: BaseTableViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
       //如果没有登录，就设置未登录信息
        if !userLogin {
           visitorView.setupVisitorInfo(isHome: true, imageName: "visitordiscover_feed_image_house", message: "关注一些人，回到这里看看有什么惊喜")
        }
        
        //初始化导航条
        setupNav()
        
        
    }

    private func setupNav(){
     
        //1.初始化左右按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem.creatbarButtonItem(imageName: "navigationbar_friendattention", target: self, action: #selector(HomeTableViewController.leftItemClick))
        navigationItem.rightBarButtonItem = UIBarButtonItem.creatbarButtonItem(imageName: "navigationbar_pop", target: self, action:#selector(HomeTableViewController.rightItemClick))

        //2.初始化标题按钮
        
        let titleBtn = TitleButton()
        titleBtn.setTitle("武雪建 ", for: .normal)
        titleBtn.addTarget(self, action: #selector(HomeTableViewController.titleBtnClick(btn:)), for: .touchUpInside)
        navigationItem.titleView = titleBtn
    }
    
    func titleBtnClick(btn:TitleButton) {
        btn.isSelected = !btn.isSelected
    }
    
    
    func leftItemClick() {
        print("左按钮")
    }
    
    func rightItemClick() {
        print("右按钮")
    }
    
//    private func creatbarButtonItem(imageName:String,target:AnyObject?, action:Selector) -> UIBarButtonItem{
//        
//        let btn = UIButton()
//        btn.setImage(UIImage(named:imageName), for: .normal)
//        btn.setImage(UIImage(named:imageName+"_highlighted"), for: .highlighted)
//        btn.addTarget(target, action: action, for: .touchUpInside)
//        btn.sizeToFit()
//        return UIBarButtonItem(customView: btn)
//    }
    
   
}
